import path from 'path'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers'
import {createSvgIconsPlugin} from "vite-plugin-svg-icons";

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        Components({
            resolvers: [AntDesignVueResolver({
                    importStyle: false
                }
            )]
        }),
        createSvgIconsPlugin({
            iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')],
            symbolId: 'icon-[dir]-[name]',
        })
    ],
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: `@import "./src/style/iframe.scss";`
            }
        }
    },
    resolve: {
        alias: {
            '@': path.resolve(__dirname, './src'),
        },
    },
    server: {
        /*proxy: {
            '/api': {
                target: 'https://www.fastmock.site/mock/d03ac9fc9b575cfe1ddb2bb8a1357eed',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '/_mock_'),
            }
        }*/
    },
    envPrefix: 'ENV_'
})